$(function () {
    $.post(Feng.ctxPath + "/tc/getLists", function (data) {
        var txt = '';
        data.forEach(function (key, value) {
            txt += '<div style="width: 20%"><span class="checkboxStyle">' +
                '<input class="checkboxClass" type="radio" name="about" value="' + key.tcName + '" id="click_' + value + '"></span>' +
                '<label class="labelStyle" for="click_' + value + '" style="font-weight: 500;margin-left: 10px;">' + key.tcName + '</label></div>';
        });
        document.getElementById('tcBox').innerHTML = txt;
    }, "json");
});

$("#tcBox").on('click', '.checkboxStyle', function () {
    $(this).children().attr('checked', 'true');
    $(this).addClass('selection').parent().siblings().children('.checkboxStyle').removeClass('selection');
});

$("#submission").click(function () {
    var id = $("#id").val();
    var tcName = $("input[name='about']:checked").val();
    if (tcName == "" || tcName == null) {
        alert("请选择一个TC！");
        return;
    }
    var remarks = $("#remarks").val();
    if (remarks == "" || remarks == null) {
        alert("请填写备注！");
        return;
    }
    $.ajax({
        url: Feng.ctxPath + "/customer/orthodonticsChoiceTc",
        type: 'POST',
        data: {
            id: id,
            remarks: remarks,
            tcName: tcName
        },
        success: function (data) {
            Feng.success("保存成功!");
            window.parent.orthodonticsTable.table.refresh();
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        },
        error: function (data) {
            alert("权限被限制，请联系管理员！");
        }
    })
});